#include "HMap.h"
#include "JRenderer.h"



///////////////////  HTile ///////////////////////////
HTile::HTile(float x,float y,u32 evd,u8 els,JTexture *tex)
{
	mX = x;
	mY = y;
	mEvd = evd;
	mMovEls = els;

	mPic = new JQuad(tex,mX,mY,32,32);
}
HTile::~HTile(void)
{
	delete mPic;
}

u32	HTile::GetEvd()
{
	return mEvd;
}
u8	HTile::GetMovEls()
{
	return mMovEls;
}
JQuad* HTile::GetPic()
{
	return mPic;
}

///////////			HMap			///////////

HMap::HMap(void)
{
	int i;
	char buf[5];
	char path[20] = "pics/Tilesets/0";
	char ext[5] = ".png";

	JRenderer* renderer = JRenderer::GetInstance();
	for (i = 1;i <= 50;i++)
	{	
		char fn[100];
		memset(fn,0,100);
		strcat(fn,path);
		if (i < 10) 
			strcat(fn,"0");
		strcat(fn,itoa(i,buf,10));
		strcat(fn,ext);

		mTextures[i] = renderer->LoadTexture(fn);
	}
}

HMap::~HMap(void)
{
	delete [] mTextures;
}

JTexture* HMap::GetTexture(u8 index)
{
	return mTextures[index];
}